package com.webserver.http;

import java.util.HashMap;
import java.util.Map;

public class Demo {

    private String requestURI;
    private String queryString;
    private Map<String,String> parameters = new HashMap<>();

    public static void main(String[] args) {
        Map<String,String> parameters = new HashMap<>();
        String uri ="/myweb/regUser?username=569569&password=s&nickname=s&age=1";
//        int d = uri.indexOf("?");
//        System.out.println(d);
//        String line = uri.substring(d+1);
//        String[] arr = line.split("\\&");
//        System.out.println(line);
//        System.out.println(arr[0]);
//        System.out.println(arr[1]);
//        System.out.println(arr[2]);
//        System.out.println(arr[3]);
        int d1 = uri.indexOf("?");
        String requestURI = uri.substring(0,d1);
        String queryString = uri.substring(d1+1);
        String[] arr1 = queryString.split("\\&");

        for(String line1 : arr1){
            String[] arr2 = line1.split("=");
            parameters.put(arr2[0],arr2[1]);
        }
        System.out.println(requestURI);
        System.out.println(queryString);
        System.out.println(arr1[0]);
        System.out.println(arr1[1]);
        System.out.println(arr1[2]);
        System.out.println(arr1[3]);
        System.out.println(parameters);



    }
}
